package com.windowes.weichang.utils;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

import static com.windowes.weichang.common.Const.Security.EXPIRATION_TIME;
import static com.windowes.weichang.common.Const.Security.SECRET;

public class JwtUtil {

    public static String generateJwt(String subject) {
        //生成token
        String token = Jwts.builder()
                .setSubject(subject)
                .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
                .signWith(SignatureAlgorithm.HS512, SECRET.getBytes())
                .compact();
        return token;
    }


}
